namespace KPIS.GERP.Models.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class update0149 : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.hrm_mp_position_work_on_duty", "to_emp_seq", "dbo.hrm_ps_employees");
            DropIndex("dbo.hrm_mp_position_work_on_duty", new[] { "to_emp_seq" });
            AddColumn("dbo.hrm_mp_position_work_on_duty", "to_pos_seq", c => c.Int());
            AddForeignKey("dbo.hrm_mp_position_work_on_duty", "to_pos_seq", "dbo.hrm_mp_positions", "pos_seq");
            CreateIndex("dbo.hrm_mp_position_work_on_duty", "to_pos_seq");
            DropColumn("dbo.hrm_mp_position_work_on_duty", "to_emp_seq");

            Sql(@"
update hrm_mp_position_work_on_duty set to_pos_seq = 175 where wod_seq = 1;
update hrm_mp_position_work_on_duty set to_pos_seq = 55 where wod_seq = 2;
update hrm_mp_position_work_on_duty set to_pos_seq = 32 where wod_seq = 3;
update hrm_mp_position_work_on_duty set to_pos_seq = 32 where wod_seq = 4;
update hrm_mp_position_work_on_duty set to_pos_seq = 32 where wod_seq = 5;
update hrm_mp_position_work_on_duty set to_pos_seq = 32 where wod_seq = 6;");

            Sql(@"
update IcmMasPurchaseMethod set amountmin = 0,         amountmax = 499999.99       where pcmethodid = 1;
update IcmMasPurchaseMethod set amountmin = 500000.00, amountmax = 999999999999    where pcmethodid = 2;
update IcmMasPurchaseMethod set amountmin = 500000.00, amountmax = 999999999999    where pcmethodid = 3;
update IcmMasPurchaseMethod set amountmin = 0,         amountmax = 0               where pcmethodid = 4;
update IcmMasPurchaseMethod set amountmin = 1,         amountmax = 1               where pcmethodid = 5;
update IcmMasPurchaseMethod set amountmin = 0,         amountmax = 999999999       where pcmethodid = 6;");
        }
        
        public override void Down()
        {
            AddColumn("dbo.hrm_mp_position_work_on_duty", "to_emp_seq", c => c.Int());
            DropIndex("dbo.hrm_mp_position_work_on_duty", new[] { "to_pos_seq" });
            DropForeignKey("dbo.hrm_mp_position_work_on_duty", "to_pos_seq", "dbo.hrm_mp_positions");
            DropColumn("dbo.hrm_mp_position_work_on_duty", "to_pos_seq");
            CreateIndex("dbo.hrm_mp_position_work_on_duty", "to_emp_seq");
            AddForeignKey("dbo.hrm_mp_position_work_on_duty", "to_emp_seq", "dbo.hrm_ps_employees", "emp_seq");
        }
    }
}
